﻿

Imports System.Web
Imports System.Web.Services
Imports System.Xml
Imports System.Text
Imports System.Data
Imports System.Data.SqlClient

<%@ WebHandler Language="VB" Class="RSSFeed">

Public Class RSSFeed
    Implements System.Web.IHttpHandler

    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

        context.Response.ContentType = "text/xml"
        context.Response.ContentEncoding = System.Text.Encoding.UTF8
        context.Response.Cache.SetExpires(DateAndTime.Now.AddSeconds(3600))
        context.Response.Cache.SetCacheability(HttpCacheability.Public)


    End Sub

    'create RSS xml document
    Dim xml As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
      xml.Formatting = Formatting.Indented
      xml.WriteStartDocument()
      xml.WriteStartElement("rss")
      xml.WriteAttributeString("version", "2.0")


    ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

    Private Function GetArticles() As DataSet
        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Prototype.accdb;Persist Security Info=True")
        Dim cmd as new sqlcommand("my_stored_procedure",conn)
        cmd.CommandType = CommandType.StoredProcedure

        Dim ds As New DataSet
        Dim da As New SqlDataAdapter(cmd)
        da.Fill(ds)
        conn.close()
        cmd.Dispose()
        conn.dispose()

    End Function

    Private Function conn() As Object
        Throw New NotImplementedException
    End Function

End Class